package com.solidtrust.admin.schedule;

import java.util.Date;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import com.solidtrust.common.FreePersister;
import com.solidtrust.util.DateUtil;

@Controller
public class GanjiSoldPriceController {

	private static final Logger log4j = Logger.getLogger(GanjiSoldPriceController.class);
	@PersistenceContext EntityManager em;
	@Autowired FreePersister free;
	
	@RequestMapping("/ganjisoldprice")
	public int calc(){
		Date d = new Date();
		String month = DateUtil.date2String1(d);
		
		//clear
		String delQl = "delete from GanjiPriceProduct where month = '" + month + "'";
		int count = free.executeNativeQuery(delQl);
		log4j.info("delete " + count + "GanjiPriceProduct records in " + month);
		
		//
		return 0;
	}
}
